﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Xts
{
    namespace XInterBank
    {
        namespace TradingClient
        {
            public class XOrderDelivery_SendOrder_Cookies
            {
                protected string x_customOrderId;
                public string CustomOrderId{ get{ return x_customOrderId; } }

                public XOrderDelivery_SendOrder_Cookies(string customOrderId)
                {
                    x_customOrderId = customOrderId;
                }
            }

            public class XOrderDelivery_CancelOrder_Cookies
            {
                protected XCancelOrderReq x_cancelOrderReq;
                public XCancelOrderReq CancelOrderReq { get { return x_cancelOrderReq; } }

                public XOrderDelivery_CancelOrder_Cookies(XCancelOrderReq cancelOrderReq)
                {
                    x_cancelOrderReq = cancelOrderReq;
                }
            }

            public class XOrderDelivery_BatchCancelOrder_Cookies
            {
                protected XCancelOrderReq[] x_cancelOrderReqList;
                public XCancelOrderReq[] CancelOrderReqList { get { return x_cancelOrderReqList; } }

                public XOrderDelivery_BatchCancelOrder_Cookies(XCancelOrderReq[] cancelOrderReqList)
                {
                    x_cancelOrderReqList = cancelOrderReqList;
                }
            }

            public interface IXAmiOrderDeliveryCBHandler
            {
                void OnSendOrder(XSendOrderRsp rsp, XOrderDelivery_SendOrder_Cookies cookies);
                void OnFailureSendOrder(XOrderDelivery_SendOrder_Cookies cookies);
                void OnSendMarketMakingOrder(XSendOrderRsp rsp, XOrderDelivery_SendOrder_Cookies cookies);
                void OnFailureSendMarketMakingOrder(XOrderDelivery_SendOrder_Cookies cookies);
                void OnCancelOrder(XCancelOrderRsp rsp, XOrderDelivery_CancelOrder_Cookies cookies);
                void OnFailureCancelOrder(XOrderDelivery_CancelOrder_Cookies cookies);
                void OnBatchCancelOrder(XCancelOrderRsp[] rsp, XOrderDelivery_BatchCancelOrder_Cookies cookies);
                void OnFailureBatchCancelOrder(XOrderDelivery_BatchCancelOrder_Cookies cookies);
            }

            public class XAmiOrderDelivery_SendOrderCallback
            {
                protected XOrderDelivery_SendOrder_Cookies x_cookies;
                protected IXAmiOrderDeliveryCBHandler x_handler;
                protected Ice.Logger x_logger;

                public XAmiOrderDelivery_SendOrderCallback(XOrderDelivery_SendOrder_Cookies cookies, 
                    ref IXAmiOrderDeliveryCBHandler handler, ref Ice.Logger logger)
                {
                    x_cookies = cookies;
                    x_handler = handler;
                    x_logger = logger;
                }

                public void SendOrderCB(XSendOrderRsp rsp)
                {
                    x_handler.OnSendOrder(rsp, x_cookies);
                }

                public void FailureSendOrderCB(Ice.Exception ex)
                {
                    x_logger.error(ex.Message);
                    x_handler.OnFailureSendOrder(x_cookies);
                }
                
            }

            public class XAmiOrderDelivery_SendMarketMakingOrderCallback
            {
                protected XOrderDelivery_SendOrder_Cookies x_cookies;
                protected IXAmiOrderDeliveryCBHandler x_handler;
                protected Ice.Logger x_logger;

                public XAmiOrderDelivery_SendMarketMakingOrderCallback(XOrderDelivery_SendOrder_Cookies cookies, 
                    ref IXAmiOrderDeliveryCBHandler handler, ref Ice.Logger logger)
                {
                    x_cookies = cookies;
                    x_handler = handler;
                    x_logger = logger;
                }

                public void SendMarketMakingOrderCB(XSendOrderRsp rsp)
                {
                    x_handler.OnSendMarketMakingOrder(rsp, x_cookies);
                }

                public void FailureSendMarketMakingOrderCB(Ice.Exception ex)
                {
                    x_logger.error(ex.Message);
                    x_handler.OnFailureSendMarketMakingOrder(x_cookies);
                }
            }

            public class XAmiOrderDelivery_CancelOrderCallback
            {
                protected XOrderDelivery_CancelOrder_Cookies x_cookies;
                protected IXAmiOrderDeliveryCBHandler x_handler;
                protected Ice.Logger x_logger;

                public XAmiOrderDelivery_CancelOrderCallback(XOrderDelivery_CancelOrder_Cookies cookies, 
                    ref IXAmiOrderDeliveryCBHandler handler, ref Ice.Logger logger)
                {
                    x_cookies = cookies;
                    x_handler = handler;
                    x_logger = logger;
                }

                public void CancelOrderCB(XCancelOrderRsp rsp)
                {
                    x_handler.OnCancelOrder(rsp, x_cookies);
                }

                public void FailureCancelOrderCB(Ice.Exception ex)
                {
                    x_logger.error(ex.Message);
                    x_handler.OnFailureCancelOrder(x_cookies);
                }
            }

            public class XAmiOrderDelivery_BatchCancelOrderCallback
            {
                protected XOrderDelivery_BatchCancelOrder_Cookies x_cookies;
                protected IXAmiOrderDeliveryCBHandler x_handler;
                protected Ice.Logger x_logger;

                public XAmiOrderDelivery_BatchCancelOrderCallback(XOrderDelivery_BatchCancelOrder_Cookies cookies, 
                    ref IXAmiOrderDeliveryCBHandler handler, ref Ice.Logger logger)
                {
                    x_cookies = cookies;
                    x_handler = handler;
                    x_logger = logger;
                }

                public void BatchCancelOrderCB(XCancelOrderRsp[] rsp)
                {
                    x_handler.OnBatchCancelOrder(rsp, x_cookies);
                }

                public void FailureBatchCancelOrderCB(Ice.Exception ex)
                {
                    x_logger.error(ex.Message);
                    x_handler.OnFailureBatchCancelOrder(x_cookies);
                }
            }
        }
    }
}
